<template>
  <a-table :data="data.tableData" :pagination="false">
    <template #columns>
      <a-table-column title="序号">
        <template #cell="{ rowIndex }">{{ rowIndex + 1 }} </template>
      </a-table-column>
      <a-table-column title="卫星名称" data-index="satName" />
      <a-table-column title="参数名称" data-index="paramName" />
      <a-table-column title="参数代号" data-index="paramCode" />
      <a-table-column title="关联表达式名称" data-index="name" />
      <a-table-column title="关联表达式" data-index="expression" />
      <a-table-column title="星上时间" data-index="satTimestamp" />
      <a-table-column title="正常上限" data-index="upperLimit" />
      <a-table-column title="正常下限" data-index="lowerLimit" />
      <a-table-column title="计算结果" data-index="result" />
    </template>
  </a-table>
  <a-pagination
    class="my-1"
    style="float: right; margin-right: 20px; margin-top: 20px; justify-content: end"
    :total="data.paginationData.total"
    :current="data.paginationData.page"
    :page-size="data.paginationData.pageSize"
    show-total
    show-jumper
    show-page-size
    @change="handleCurrentChange"
    @page-size-change="handleSizeChange"
  />
</template>

<script setup>
import { reactive, onMounted } from 'vue'
import { apiHome } from '@/api/strategy.js'

const data = reactive({
  tableData: [],
  paginationData: {
    pageNum: 1,
    pageSize: 10,
    total: 0
  }
})

const handleCurrentChange = (page) => {
  data.paginationData.pageNum = page
  getList()
}

const handleSizeChange = (size) => {
  data.paginationData.pageSize = size
  getList()
}

const getList = async () => {
  const res = await apiHome.getAnalyseList(data.paginationData)
  if (res.code === 200) {
    data.tableData = res.data.list
    data.paginationData.total = +res.data.total
  }
}

onMounted(() => {
  getList()
})
</script>

<style></style>
